{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true,
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "# 使用最小二乘法求解线性回归"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "outputs": [],
   "source": [
    "def loaddata():\n",
    "    data = np.loadtxt('data/data1.txt',delimiter=',')\n",
    "    n = data.shape[1]-1 #特征数\n",
    "    X = data[:,0:n]\n",
    "    y = data[:,-1].reshape(-1,1)\n",
    "    return X,y"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "outputs": [],
   "source": [
    "X_orgin,y = loaddata()\n",
    "X = np.insert(X_orgin, 0, values=1, axis=1)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "根据如下公式求解theta\n",
    "\n",
    "<img src=\"images/10.png\" width=\"200\" align=\"left\"/>"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "outputs": [],
   "source": [
    "theta = np.linalg.inv(X.T.dot(X)).dot(X.T).dot(y)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "outputs": [
    {
     "data": {
      "text/plain": "array([[-3.89578088],\n       [ 1.19303364]])"
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "theta"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "outputs": [
    {
     "data": {
      "text/plain": "[<matplotlib.lines.Line2D at 0x2bc21195af0>]"
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": "<Figure size 432x288 with 1 Axes>",
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXIAAAD5CAYAAAA6JL6mAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAgVElEQVR4nO3de3xU5Z0/8M83MWjACyKokJIGb2FVVtCU2tIqYFsQbKX0VS/bi7vtlrpb20Vt2oC2YrWSlqq13d126cqvWi+LrZCyggIKFrULbbiJCHjBQBkQghhUiJDL9/fHzMTJnHNmzsycy3NmPu/Xy1eSZ25fJsdPnnnO8zxHVBVERBRdZWEXQEREhWGQExFFHIOciCjiGORERBHHICciijgGORFRxB2T7Q4iMhTAgwBOB9ANYK6q3iciswB8A0Br4q4zVXVJpucaOHCg1tTUFFQwEVGpWbt27X5VHeR0e9YgB9AJ4GZVXSciJwBYKyLLE7fdq6o/c1tMTU0Nmpub3d6diIgAiMiOTLdnDXJV3QNgT+L7d0VkC4Aqb8ojIqJC5TRGLiI1AEYBWJNoukFEXhSReSJystfFERFRdq6DXESOB/A4gOmq+g6AXwE4E8BIxHvsdzs8bpqINItIc2trq91diIioAK6CXEQqEA/xh1V1AQCo6l5V7VLVbgC/ATDa7rGqOldV61S1btAgx7F6IiLKU9YgFxEBcD+ALap6T0r74JS7fR7AS96XR0RE2biZtTIGwFcAbBKRDYm2mQCuFZGRABRAC4Bv+lAfEVGkNa2PYc7Sbdjd1o4h/StRP6EWU0Z5O1/EzayV5wGIzU0Z54wTEZW6pvUxzFiwCe0dXQCAWFs7ZizYBACehjlXdhIR+WTO0m09IZ7U3tGFOUu3efo6DHIiIp/sbmvPqT1fDHIi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7QbwG4c6jHqPReQYAFMBzHe6T1jvr4hUIB6KD6vqgkSzscexQ72+HcNGBbmI9BORE5LfI35y4KW0uy0C8FWJuxjAweTHqxA59mJE5PTEuCNEZDTi7/lbAdZmZxGA6xLfXwfgjzb3+SuAs0VkWOITxzWJx4VCRCYC+D6Az6nqYYf7uDl+ApF23ubzDnUY9R4D+BSAraq6y+7GsN7fxP8/9wPYoqr3pNxk5HHsVK+vx7CfZ2/zONt7BuJnlTcC2AzglkT79QCuT3wvAP4D8TPRmwDUhVxzX8SD+aSUttR6b0j8WzYifoLj4wHX9yiAPQA6EO+dfB3AKQCeAfBq4uuAxH2HAFiS8thJiJ9xfz35uwix5tcQH+vckPjv1+k1Ox0/IdX7u8Tx+SLiwTHYlPfYrt5E+2+Tx23KfU14fz+B+HDIiym//0mmHscZ6vXtGObKTiKiiDNqaIWIiHLHICciijgGORFRxDHIiYgijkFORBRxDHIioohjkBMRRRyDnIgo4v4/9ohDudpyWgQAAAAASUVORK5CYII=\n"
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(X_orgin,y)\n",
    "h_theta = theta[0]+theta[1]*X_orgin\n",
    "plt.plot(X_orgin,h_theta)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}